import { defineStore } from "pinia";
import { reactive } from "vue";

export const useUserStore = defineStore(
    "userStore",
    () => {
        const user = reactive({
            adminId: "",
            adminName: "",
            password: "",
            token: "",
        });

        const setUser = (newUser) => {
            user.adminId = newUser.adminId;
            user.adminName = newUser.adminName;
            user.password = newUser.password;
            user.token = newUser.token;
        };

        const clearUser = () => {
            user.adminId = "";
            user.adminName = "";
            user.password = "";
            user.token = "";
        };

        return { user, setUser, clearUser };
    },
    {
        persist: true,
    }
);
